import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

export default new Vuex.Store({
    state: {
        token: localStorage.getItem("token") || "",
        //如果本地存储中有token的话那么就从里面拿到token，如果没有token就是空
    },
    mutations: {
        setToken(state, data) {
            state.token = data;
            localStorage.setItem("token", data);
        },
        //settoken方法，把token存进本地存储里
    },
});